#!coding=utf-8

import time
from concurrent.futures import ThreadPoolExecutor,wait,ALL_COMPLETED


def action(second):
    print(second)
    time.sleep(second)
    return second


lists=[4,5,2,3]
all_task = []
with ThreadPoolExecutor(max_workers=2) as pool:
    for second in lists:
        all_task.append(pool.submit(action, second))

    # 主线程等待所有子线程完成
    wait(all_task, return_when=ALL_COMPLETED)
    print("----complete-----")
